/**
 * Created with Intellij IDEA.
 * Description:
 * User:Lenovo
 * Date:2024-12-03
 * Time:21:58
 */
public class Text {
    public static int fun(int i) {
        int count = 0;
        if(i>9) {
            while(i!=0) {
                count++;
                i/=10;
            }
            return count;
        }else{
                return 1;
            }
    }
    public static int fun2(int math,int count){
        int sum = 1;
        for (int i = 0; i < count; i++) {
          sum*=math;
        }
        return sum;
    }
    public static void main(String[] args) {
        int count = 0;
        int sum = 0;
        for (int i = 0; i < 999999; i++) {
            sum = 0;
            int m = i;
            count = fun(m);
            for (int k = 0; k < count; k++) {
                int math = m%10;
                int z= fun2(math,count);
                sum+=z;
                m/=10;
            }
            if(sum==i){
                System.out.println(i);
            }
        }
    }
}

